Repository navigation
feat(easy-domain): add VAT with testing - #574
Merged
Merged
Conversation
| } | ||
|
|
||
| get isValid(): boolean { | ||
| const shopCode = (ctx.request as any)?.shopCode; |
Collaborator
There was a problem hiding this comment.
You can't use request context like this in a generic library, please move the country to the construtor. Maybe optional with a default on NL. So new VAT('123', 'NL')
| } | ||
| } | ||
|
|
||
| export const toVAT = (vat?: unknown): VAT => new VAT(vat); |
Collaborator
There was a problem hiding this comment.
I would go for vat instead. Same as email and the others
Contributor
Author
|
@woutervanbakel pushed the fixes |
| export class VAT extends Value { | ||
| private readonly country: string; | ||
|
|
||
| constructor(vat?: unknown, country = 'NL') { |
Collaborator
There was a problem hiding this comment.
vat needs to be required.
| constructor(vat?: unknown, country = 'NL') { | ||
| const cleaned = replaceAll(text(vat).trim, '.', ''); | ||
| super(cleaned.toString()); | ||
| this.country = country; |
Collaborator
There was a problem hiding this comment.
country always toUpper.
Collaborator
There was a problem hiding this comment.
text(country).trim.upper.toString()
|
|
||
| constructor(vat?: unknown, country = 'NL') { | ||
| const cleaned = replaceAll(text(vat).trim, '.', ''); | ||
| super(cleaned.toString()); |
Collaborator
There was a problem hiding this comment.
text(vat).trim.replace('.', '').toString()
…e while recleaning VAT input
Contributor
Author
|
@woutervanbakel fixed the above |
Collaborator
|
Thanks for your addition! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using validator.js added in easy domain with testing and sanitization for easy storage